package testcode;

import com.example.start.PeopleInfo;
import com.google.protobuf.InvalidProtocolBufferException;

import java.util.Arrays;

public class FastStart {
    public static void main(String[] args) throws InvalidProtocolBufferException {
        PeopleInfo p1 = PeopleInfo.newBuilder().setName("张三").setAge(20).build();

        //序列化
        byte[] bytes = p1.toByteArray();
        System.out.println("序列化结果为：");
        System.out.println(Arrays.toString(bytes));

        //反序列化
        PeopleInfo p2 = PeopleInfo.parseFrom(bytes);

        System.out.println("反序列化结果为：");
        System.out.println("姓名：" + p2.getName() + " 年龄：" + p2.getAge());
    }
}